package mfh.liveroam.persistence;

import java.io.ByteArrayInputStream;
import java.io.InputStream;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Blob;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class RouteBean {

	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private String albumId;

	@Persistent
	private Blob gpx;
	@Persistent
	private int hourOffset = 0;

	public RouteBean(String albumId, byte[] gpxBytes, int hourOffset) {
		super();
		this.albumId = albumId;
		gpx = new Blob(gpxBytes);
		this.hourOffset = hourOffset;

	}

	public String getAlbumId() {
		return albumId;
	}

	public int getHourOffset() {
		return hourOffset;
	}

	public void setAlbumId(String albumId) {
		this.albumId = albumId;
	}

	public InputStream getGpxStream() {
		InputStream stream = new ByteArrayInputStream(gpx.getBytes());
		return stream;
	}

}
